import { createStore, applyMiddleware } from "redux";
import { addTodo } from "./actions";
import rootReducer from "./reducers";

function logger(state) {
    return (next) => (action) => {
        console.log(state);
        console.log('will dispatch', action);
 
        let returnValue = next(action);

        console.log('state afmkkkter dispatch', state.getState());

        return returnValue;
    }
}

const store = createStore(rootReducer, applyMiddleware(logger));

store.subscribe((...args) => {
   console.log("dd:", ...args);
});
console.log(store);
console.log(store.getState());
store.dispatch(addTodo("hello"));
console.log(store.getState());
console.log(11);
